package com.android.hedgehog;

import android.graphics.Color;

import com.android.hedgehog.framework.Game;
import com.android.hedgehog.framework.Graphics;
import com.android.hedgehog.framework.Screen;

public class LockBufferScreen extends Screen {
	enum Phase {
		Close, Pause, Open
	}

	Graphics graphics;
	float accumulatedTime;
	int yPos;
	Phase phase;

	public LockBufferScreen(Game game) {
		super(game);
		graphics = game.getGraphics();
		phase = Phase.Close;
		yPos = 0;
	}

	@Override
	public void update(float deltaTime) {

		if (phase == Phase.Close) {
			yPos += 8;
			if (yPos >= 240)
				phase = Phase.Pause;
		}

		if (phase == Phase.Pause) {
			accumulatedTime += deltaTime;
			if (accumulatedTime > .5)
				phase = Phase.Open;
		}

		if (phase == Phase.Open) {
			yPos -= 8;
			if (yPos <= 0){
				dispose();
				
			}
		}

	}

	@Override
	public void present(float deltaTime) {
		graphics.drawUniversalRect(0, 0, 320, yPos, false, true, 1, 255, Color.BLACK);
		graphics.drawUniversalRect(0, 480 - yPos, 320, 480, false, true, 1, 255, Color.BLACK);

	}

	@Override
	public void pause() {

	}

	@Override
	public void resume() {

	}

	@Override
	public void dispose() {

	}

}
